#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int n,m;
const ll MOD=1000000007;
const int N=1e5+50;
ll exgcd(ll a,ll b,ll &x,ll &y){
    if(!b){
        x=1;
        y=0;
        return a;
    }
    ll d=exgcd(b,a%b,x,y);
    ll t=x;
    x=y;
    y=t-a/b*y;
    return d;
}
ll inv(ll a,ll m){
    ll x,y;
    ll d=exgcd(a,m,x,y);
    if(d==1){
        return (x%m+m)%m;
    }
    return -1;
}
ll pw[N];
int main(void){
    pw[0]=1;
    pw[1]=1;
    for(ll i=2;i<N;i++){
        pw[i]=pw[i-1]*i%MOD;
    }
    while(~scanf("%d%d",&n,&m)){
        if(n==2 || m==2){
            printf("1\n");
            continue;
        }
        if(n==3){
            printf("%d\n",m-1);
            continue;
        }
        ll ans=1;
        for(ll i=n-1;i<=(n-1+m-3);i++){
            ans=(ans*i)%MOD;
        }
        ll g=inv(pw[m-2],MOD);
        printf("%lld\n",(ans*g)%MOD);
    }
    return 0;
}